/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ac.za.cput.xalisa.designpatterns.creational.builder;

/**
 *
 * @author Enkosi
 */
public class MealBuilder {

    public static class Builder {

        // mandatory
        private String choice;
        // optional
        private String coke;
        private String coffee;
        private String whiteCream;

        public Builder(String choice) {
            this.choice = choice;
        }

        public Builder coke(String coke) {
            this.coke = coke;
            return this;
        }

        public Builder coffee(String coffee) {
            this.coffee = coffee;
            return this;
        }

        public Builder whiteCream(String whiteCream) {
            this.whiteCream = whiteCream;
            return this;
        }

        public MealOrder build() {
            return getMealOrder(this);
        }

        private MealOrder getMealOrder(Builder builder) {
            MealOrder mealOrder = new MealOrder();
            mealOrder.setChoice(builder.choice);
            mealOrder.setCoke(builder.coke);
            mealOrder.setCoffee(builder.coffee);
            mealOrder.setWhiteCream(builder.whiteCream);

            return mealOrder;
        }
    }
}
